package com.behavior.chainofresponsibility;
 

public abstract class Logger {
	
	/**
	 * 优先级.
	 */
	public static int INFO = 1;
	
	/**
	 * 优先级.
	 */
	public static int DEBUG = 2;
	
	/**
	 * 优先级.
	 */
	public static int ERROR = 3;
	
	/**
	 * 下一责任.
	 */
	protected Logger nextLogger;
	
	protected int level;
 
	public Logger setNextLogger(Logger logger) {
		this.nextLogger = logger;
		return logger;
	}
 
	public void logMessage(int level, String message) {
	   
	   if (this.level == level) {
		   show(message);
	   } else if (this.nextLogger != null) {
		   this.nextLogger.logMessage(level, message);
	   } else {
		   System.out.println("暂无法处理");
	   }
	}
 
	public void showMessage(String message) {
		show(message);
		if (this.nextLogger != null) {
			this.nextLogger.showMessage(message);
		}
	}
 
	protected abstract void show(String paramString);
	
}
